from csdn.items import CsdnItem
import scrapy
from scrapy.http import Request

class AuthorspiderSpider(scrapy.Spider):
    name = 'authorSpider'
    allowed_domains = ['blog.csdn.net']
    start_urls = ['https://blog.csdn.net/weixin_41055260']

    def parse(self, response):
        index="//ul[@class='SG_pages']/li/a/@href"
        item="////span[@class='atc_title']/a/@href"


        subSelector = response.xpath(index)
        for sub in subSelector:
            yield Request(sub.extract())
        itemSelector=response.xpath(item)
        for item in itemSelector:
            yield Request(item.extract(), callback=self.parse_item)
    def parse_item(self,response):
        title = "//h2"
        read = "//div[@class='articalInfo']//span[1]"
        item=CsdnItem()
        item['title']=response.xpath(title).extract()
        item['read']=response.xpath(read).extract()
        return item